/**
 * This file is part of Idegen, the application to create IDE project files.
 *
 * @copyright Copyright (c) 2011-2012, Walter Tamboer http://waltertamboer.nl
 * @file Idegen/Application/Application.cpp
 */

#include "Idegen/PrecompiledHeader.hpp"
#include "Idegen/Application/Settings.hpp"
#include "Idegen/Application/Application.hpp"
#include "Idegen/Idegen/IdegenGenerator.hpp"
#include "Idegen/Idegen/IdegenGeneratorType.hpp"
#include "Idegen/Generator/IGenerator.hpp"
#include "Idegen/Generator/VisualStudioGenerator.hpp"
#include "Idegen/Generator/VS2010Generator.hpp"
#include "Idegen/IO/FileSystem.hpp"

namespace Idegen
{
	Application::Application( const std::string& settingsFile )
	{
		m_Settings = new Settings( settingsFile );
	}
	
	Application::Application( const std::string& settingsFile, const std::string& basePath )
	{
		m_Settings = new Settings( settingsFile, basePath );
	}

	Application::~Application()
	{
		delete m_Settings;
	}

	bool Application::Run()
	{
		IdegenGeneratorList generators = m_Settings->GetGenerators();
		for ( IdegenGeneratorList::iterator it = generators.begin(); it != generators.end(); ++it )
		{
			IdegenGenerator* generatorDef = *it;
			IGenerator* generator = NULL;

			switch ( generatorDef->GetType() )
			{
			case IdegenGeneratorTypeNetbeans70:
				// @todo not implement yet
				break;

			case IdegenGeneratorTypeVisualStudio2005:
				// @todo not implement yet
				break;

			case IdegenGeneratorTypeVisualStudio2008:
				// @todo not implement yet
				break;

			case IdegenGeneratorTypeVisualStudio2010:
				generator = new VS2010Generator();
				break;

			default:
				// @todo log an error
				break;
			}

			if ( generator != NULL )
			{
				generator->Generate( m_Settings, generatorDef );
				delete generator;
			}
		}

		return true;
	}
}
